<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%--
代码为自动生成 Created by www.magicalcoder.com
 如果你改变了此类 read 请将此行删除
 欢迎加入官方QQ群:323237052
--%>
<!DOCTYPE html>
<html>
<head>
    <%@include file="../../common/head.jsp"%>
    <title>班级关联教师列表</title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <%@include file="../include/head.jsp"%>
</head>
<body class="skin-blue">
<header class="header">
    <%@include file="../include/top.jsp"%>
</header>
<div class="wrapper row-offcanvas row-offcanvas-left">
    <aside class="left-side sidebar-offcanvas">
        <%@include file="../include/left.jsp"%>
    </aside>
    <aside class="right-side">
        <section class="content-header">
            <h1>
                班级关联教师列表 
                <c:if test="${ adminPriority!=null && adminPriority.canInsert}">
                    <a class="btn btn-app" href="admin/class_teacher/detail"><i class="fa fa-plus-square-o"></i>新增</a>
                </c:if>
            </h1>
            <ol class="breadcrumb">
                <li><a href="admin/index"><i class="fa fa-dashboard"></i> 主页</a></li>
                <li class="active">班级关联教师列表</li>
            </ol>
        </section>
        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header ui-sortable-handle">
                            <i class="fa fa-search"></i>
                            <h3 class="box-title">查询区域</h3>
                            <div class="box-tools pull-right">
                                <button type="button" class="btn bg-teal btn-sm" data-widget="collapse"><i class="fa fa-minus"></i></button>
                                <button type="button" class="btn bg-teal btn-sm" data-widget="remove"><i class="fa fa-times"></i></button>
                            </div>
                        </div>
                        <div class="box-body">
                            <div class="box-tools">
                                <div class="form">
                                    <div class="box-body">
                                        <div class="row">
                                             <div class="col-lg-2">
                                                <div class="form-group">
                                                    <label for="classIdFirst">班级表主键</label>
                                                    <select multiple="multiple" class="form-control multiple-select2-ajax" id="classIdFirst"  name="classIdFirst" foreignTableName="classes" foreignJavaField="id" selectValue="" values="" openUrl="admin/classes/detail_param?id="></select>
                                                </div>
                                            </div>                                             <div class="col-lg-2">
                                                <div class="form-group">
                                                    <label for="teacherIdFirst">老师表主键</label>
                                                    <select multiple="multiple" class="form-control multiple-select2-ajax" id="teacherIdFirst"  name="teacherIdFirst" foreignTableName="teacher" foreignJavaField="id" selectValue="" values="" openUrl="admin/teacher/detail_param?id="></select>
                                                </div>
                                            </div>
                                            <div class="col-lg-2">
                                                <div class="form-group">
                                                    <label for="querySubmit">&nbsp;</label>
                                                    <button class="btn btn-primary form-control" id="querySubmit">查询</button>
                                                </div>
                                            </div>

                                            <input type="hidden" id="pageIndex" name="pageIndex"  value="1">
                                            <input type="hidden" id="pageCount" name="pageCount" value="0">
                                            <input type="hidden" id="orderBySqlField" name="orderBySqlField" value="">
                                            <input type="hidden" id="descAsc" name="descAsc" value="">
                                            <input type="hidden" id="queryParamCacheKey" name="queryParamCacheKey" value="${queryParamCacheKey}">
                                            <input type="hidden" id="focusTrId" name="focusTrId" value="${focusTrId}">
                                            <input type="hidden" id="canDelete"  value="${adminPriority.canDelete}">
                                            <input type="hidden" id="canUpdate"  value="${adminPriority.canUpdate}">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="box collapsed-box">
                        <div class="box-header ui-sortable-handle">
                            <i class="fa fa-th"></i>
                            <h3 class="box-title">工具箱</h3>
                            <div class="box-tools pull-right">
                                <button type="button" class="btn bg-teal btn-sm" data-widget="collapse"><i class="fa fa-plus"></i></button>
                                <button type="button" class="btn bg-teal btn-sm" data-widget="remove"><i class="fa fa-times"></i></button>
                            </div>
                        </div>
                        <div class="box-body" style="overflow: hidden; display: none;">
                            <div class="box-tools">
                                <div class="form">
                                    <div class="row">
                                        <c:if test="${ adminPriority!=null && adminPriority.canDelete }">
                                            <div class="col-lg-1">
                                                <div class="form-group">
                                                    <input id="batchDeleteItem" class="form-control btn btn-sm btn-danger" type="button" onclick="batchDeleteItem('class_teacher')" value="批量删除">
                                                </div>
                                            </div>
                                        </c:if>
                                        <c:if test="${ adminPriority!=null && adminPriority.canTruncate}">
                                            <div class="col-lg-1">
                                                <div class="form-group">
                                                    <input class="form-control btn btn-sm btn-danger" type="button" onclick="truncateTable('class_teacher')" value="清空数据">
                                                </div>
                                            </div>
                                        </c:if>
                                        <c:if test="${ adminPriority!=null && adminPriority.canInsert}">
                                            <div class="col-lg-1">
                                                <div class="form-group">
                                                    <input class="form-control btn btn-sm btn-danger" type="button" onclick="batchCopyItem('class_teacher')" value="批量复制">
                                                </div>
                                            </div>
                                        </c:if>
                                        <c:if test="${ adminPriority!=null && adminPriority.canUpdate}">
                                            <div class="col-lg-1">
                                                <div class="form-group">
                                                    <button class="form-control btn btn-sm btn-danger" data-toggle="modal" data-target="#batchUpdateModal">批量更新</button>
                                                    <!-- 模态框（Modal） -->
                                                    <div class="modal fade" id="batchUpdateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                                        <div class="modal-dialog">
                                                            <div class="modal-content">
                                                                <div class="modal-header">
                                                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                                                        &times;
                                                                    </button>
                                                                    <h4 class="modal-title" id="myModalLabel">
                                                                        选中的记录将会被全部更新(空或者未选择的表单字段更新时将被忽略)
                                                                    </h4>
                                                                </div>
                                                                <div class="modal-body" >
                                                                    <div class="box-body form-horizontal">
                                                                        <div class="form-group">
                                                                            <label class="col-sm-3 control-label">班级表主键</label>
                                                                             <div class="col-sm-7"><select class="form-control single-select2-ajax" name="classId"  minLength="0"  foreignTableName="classes" foreignJavaField="id" selectValue="" values="${classTeacher.classId}" openUrl="admin/classes/detail_param?id="></select></div>
                                                                            <label class="col-sm-2 control-label" ><span class="validateMsg"></span></label>
                                                                        </div>
                                                                        <div class="form-group">
                                                                            <label class="col-sm-3 control-label">老师表主键</label>
                                                                             <div class="col-sm-7"><select class="form-control single-select2-ajax" name="teacherId"  minLength="0"  foreignTableName="teacher" foreignJavaField="id" selectValue="" values="${classTeacher.teacherId}" openUrl="admin/teacher/detail_param?id="></select></div>
                                                                            <label class="col-sm-2 control-label" ><span class="validateMsg"></span></label>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div class="modal-footer">
                                                                    <button type="button" class="btn btn-default" id="closeBatchUpdateModal" data-dismiss="modal">关闭
                                                                    </button>
                                                                    <button type="button" class="btn btn-primary" onclick="batchUpdateItem('class_teacher')">
                                                                        提交更改
                                                                    </button>
                                                                </div>
                                                            </div><!-- /.modal-content -->
                                                        </div><!-- /.modal -->
                                                    </div>
                                                </div>
                                            </div>
                                        </c:if>

                                        <div class="col-lg-1">
                                            <div class="form-group">
                                                <label>导出:</label>
                                            </div>
                                        </div>
                                        <div class="col-lg-1">
                                            <div class="form-group">
                                                <input type="text" class="form-control" size="2" name="start"  id="start" value="0" title="第几行" placeholder="第几行">
                                            </div>
                                        </div>
                                        <div class="col-lg-1">
                                            <div class="form-group">
                                                <input type="text"  class="form-control" size="2" name="limit" id="limit" value="20" title="每页行数,分页最大100行,导出不限制" placeholder="每页行数">
                                            </div>
                                        </div>

                                        <c:if test="${ adminPriority!=null && adminPriority.canExport}">
                                        <div class="col-lg-1">
                                            <div class="form-group">
                                                <input type="button" class="form-control btn btn-sm btn-info" onclick="exportFile('excel')" value="EXCEL导出">
                                            </div>
                                        </div>
                                            <div class="col-lg-1">
                                                <div class="form-group">
                                                    <input type="button" class="form-control btn btn-sm btn-info" onclick="exportFile('json')" value="JSON导出">
                                                </div>
                                            </div>
                                        </c:if>

                                        <c:if test="${ adminPriority!=null && adminPriority.canImport}">
                                        <div class="col-lg-1">
                                            <div class="form-group">
                                                <label title="支持excel和json">导入:</label>
                                            </div>
                                        </div>
                                        <div class="col-lg-1">
                                            <div class="form-group">
                                                <input type="file" id="importJsonFile" class="form-control btn btn-sm btn-danger" name="myfiles" onchange="importJsonFile('admin/class_teacher/import')"/>
                                            </div>
                                        </div>
                                        </c:if>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="box">
                        <div class="box-header ui-sortable-handle">
                            <i class="fa fa-table"></i>
                            <h3 class="box-title">查询结果</h3>
                            <div class="box-tools pull-right">
                                <button type="button" class="btn bg-teal btn-sm" data-widget="collapse"><i class="fa fa-minus"></i></button>
                                <button type="button" class="btn bg-teal btn-sm" data-widget="remove"><i class="fa fa-times"></i></button>
                            </div>
                        </div>
                        <div class="box-body table-responsive" style="overflow: auto">
                            <table id="example2" class="table table-bordered table-hover dataTable">
                                <thead id="thead">
                                    <tr>
                                        <th><input type="checkbox" id="checkAll"></th>
                                        <th>序号</th>
                                        <th  class="sorting" orderField="class_id">班级表主键</th>
                                        <th  class="sorting" orderField="teacher_id">老师表主键</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="tbody"></tbody>
                                <tfoot></tfoot>
                            </table>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <div class="row">
                                <div class="col-lg-12">
                                    <div class="dataTables_paginate paging_bootstrap">
                                        <ul class="pagination" id="pagination">
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- /.box-footer -->
                    </div>
                    <!-- /.box -->
                </div>
            </div>

            <c:if test="${ adminPriority!=null && adminPriority.canStatistics}">
            <!-- statistics begin-->
            <!--基础统计自定义横坐标-->
            <div class="row">
                <div class="col-xs-12">
                    <div class="box  collapsed-box">
                        <div class="box-header ui-sortable-handle">
                            <i class="fa fa-bar-chart"></i>
                            <h3 class="box-title">自定义横坐标分组统计</h3>
                            <div class="box-tools pull-right">
                                <button type="button" class="btn bg-teal btn-sm" data-widget="collapse"><i class="fa fa-plus"></i></button>
                                <button type="button" class="btn bg-teal btn-sm" data-widget="remove"><i class="fa fa-times"></i></button>
                            </div>
                        </div>
                        <div class="box-body" style="overflow: hidden; display: none;">
                            <div class="box-tools">
                                <div class="form">
                                    <div class="box-body">
                                        <div class="row">
                                            <div class="col-lg-2">
                                                <div class="form-group">
                                                    <label for="groupBySqlField">分组</label>
                                                    <select class="form-control" id="groupBySqlField" name="groupBySqlField">
                                                        <option value="id">班级关联老师表主键</option>
                                                        <option value="class_id">班级表主键</option>
                                                        <option value="teacher_id">老师表主键</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="col-lg-2">
                                                <div class="form-group">
                                                    <label for="groupStatistics">&nbsp;</label>
                                                    <button class="btn btn-primary form-control" id="groupStatistics">统计</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="box-body" id="groupStatisticsDiv">

                        </div>
                        <div class="box-footer">
                            <div class="form-group ">
                                <label class="col-sm-3 control-label"></label>
                                <div class="col-sm-9">
                                    <label type="text"  id="groupStatisticsName" value=""></label>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- statistics end-->
            </c:if>
        </section>
        <!-- /.content -->
    </aside>
    <!-- /.right-side -->
</div>
<!-- ./wrapper -->
<%@include file="../include/tail.jsp"%>
<script src="assets/admin/app/classteacher/classTeacherPaging.js" type="text/javascript"></script>
<script type="text/javascript" >
    function resetDefaultValue() {
        //外键下拉==========begin=========//
        initSingleSelect2Ajax($(".form"))
        autoSetSingleSelect2Value($(".form"))
        initMultipleSelect2Ajax($(".form"))
        autoSetMultipleSelect2Value($(".form"))
        //外键下拉==========end========//
        getItemPage()
        initOrderBy()
        bindOrderByEvent()

    }
    $(function(){
        $(".multiple-select2-basic").select2()
        initSingleSelect2Ajax($(".form"))
        autoSetSingleSelect2Value($(".form"))
        initSingleSelect2Ajax($("#batchUpdateModal"))
        autoSetSingleSelect2Value($("#batchUpdateModal"))
        initMultipleSelect2Ajax($(".form"))
        autoSetMultipleSelect2Value($(".form"))
    //分页相关==========begin==========//
        restoreBuildQueryParam($("#queryParamCacheKey").val(),resetDefaultValue)
        //查询
        $("#querySubmit").click(function(){
            $("#pageIndex").val("1")
            $("#pageCount").val("0")
            buildQueryParamCacheKeyAndSetCache(buildReqParam(),"queryParamCacheKey",getItemPage)
        })
        //批量删除
        bindCheckAllEvent();
        //批量表单验证
        validateForm2($("#batchUpdateModal"))
    //分页相关==========end==========//
    //统计=============begin==========//
        $("#groupDateCountStatistics").click(function(){
            var start = $("#start").val()
            var limit = $("#limit").val()
            var groupDateCountBySqlField = $("#groupDateCountBySqlField").val()
            if(groupDateCountBySqlField==''){
                alert("无日期字段，不支持日期汇总统计，请使用其他统计功能")
                return
            }
            var reqParam = buildReqParam();
            reqParam.groupDateCountBySqlField=groupDateCountBySqlField
            reqParam.groupDateCountByPrecision=parseInt($("#groupDateCountByPrecision").val())
            groupDateCountStatistics("class_teacher","groupDateCountStatisticsDiv",start,limit,reqParam);
        })
        $("#groupDateIntervalStatistics").click(function(){
            var start = $("#start").val()
            var limit = $("#limit").val()
            var groupDateIntervalBySqlField = $("#groupDateIntervalBySqlField").val()
            if(groupDateIntervalBySqlField==''){
                alert("无日期字段，不支持日期间隔频率统计，请使用其他统计功能")
                return
            }
            var reqParam = buildReqParam();
            reqParam.groupDateIntervalBySqlField=groupDateIntervalBySqlField
            var groupDateIntervalByPrecision=parseInt($("#groupDateIntervalByPrecision").val())
            groupDateIntervalStatistics("class_teacher","groupDateIntervalStatisticsDiv",start,limit,reqParam,groupDateIntervalByPrecision);
        })
        $("#groupStatistics").click(function(){
            var start = $("#start").val()
            var limit = $("#limit").val()
            var reqParam = buildReqParam();
            reqParam.groupBySqlField=$("#groupBySqlField").val()
            groupStatisticsDiv("class_teacher","groupStatisticsDiv",start,limit,reqParam,"groupStatisticsName");
        })
    //统计=============end============//
    })
</script>
</body>
</html>
